/* 
 * (PARI-GP) R. J. Cano, May 10 2014 
 *
 * (Acknowledgment to Charles Greathouse IV)
 *
 * Title: "Failsafe identities testing convention" Version 1.0
 *
 * Description: Use always assignments like either
 * 
 --------------------------------------
 ? t0=vector(s,j,f23(j));
 --------------------------------------
 
 * or 
 
 --------------------------------------
 ? t0=vector(s,j,numerator(g01(j,s\2)));
 --------------------------------------
 
 *
 * And try to ensure you always keep recorded a pair
 * "original definition" vs "modification"
 * where modification can be just a "clean slate"...
 *
 * Essentially a "clean slate" means that you are able
 * to replace definitions leaving the right-hand side
 * free of calls to another user-defined routines. If
 * it were impossible to be so explicit, at least keep
 * in mind the initially proposed application of the
 * "divide and conquer" strategy.
 *
 * About the notation, it is the "f" standing for "function",
 * even numbers for the "originals" and odd numbers for the
 * modifications. So simple.
 *
 * For instance:
 *   Here f01() is a factorisation for f00();
 *   Also f07() is a "clean slate" for f06();
 *
 * The main purpose of this dumb sort of re-defs succession
 * is to serve as an aid when looking for optimization or
 * keeping a log of our thoughts when analyzing sequences.
 * 
 * Below a brief example illustrating this.
 *
*/

s=    25; /* Default size for a small sample vector. */
S= 10000; /* Default size for a large sample vector, a.k.a "b-file" */

f00(n)=10^n-2^n; /* A060458 */ 
f01(n)=(2^n)*(5^n-1); 
f02(n)=f01(n+1)-f01(n);
f03(n)=(2^n)*(9*5^n-1);
f04(n)=f03(n)/(2^n)
f05(n)=(9*5^n-1);
f06(n)=f05(n)/4;
f07(n)=(9*5^n-1)/4;
f08(n)=f07(n)-1;
f09(n)=(9*5^n-1)/4-1;
f10(n)=f09(n)/5;
f11(n)=((9*5^n-1)/4-1)/5;
f12(n)=f11(n)-1;
f13(n)=((9*5^n-1)/4-1)/5-2;
f14(n)=f13(n)/9;
f15(n)=(((9*5^n-1)/4-1)/5-2)/9; /* 95n141529 would be a palindrome for n=5 if we read "5n" as 5*n !!!*/
f16(n)=(f15(n)-1)/5;            /* Also f15(5)=155 and f15(5)-1=151 ... no comments!.*/
f17(n)=((((9*5^n-1)/4-1)/5-2)/9-1)/5;
f18(n)=(f17(n)-1)/5;
f19(n)=(((((9*5^n-1)/4-1)/5-2)/9-1)/5-1)/5;
f20(n)=(f19(n)-1)/5;
f21(n)=((((((9*5^n-1)/4-1)/5-2)/9-1)/5-1)/5-1)/5; /* The sequence of absolute values for the numerators smells like a palindrome */
f22(n)=numerator((f15(n)-1)/5);
f23(n)=numerator(((((9*5^n-1)/4-1)/5-2)/9-1)/5);
/* ... */
f99(n)=-1*0; /*Yet another way to say "EOF"*/

/* Breakpoint: Proposing a recursive transformation r(x,m), where x is some input data and m some parameter */

r(x,m)=if(m==0,x,(r(x,m-1)-1)/5);

g00(x,y=s)=(r(f15(x),y));
g01(x,y=s)=(r((((9*5^(x)-1)/4-1)/5-2)/9,y)); /* It proves the already guessed presence of symmetry! */

t0=vector(s,j,numerator(g01(j,s\2)));

print("\nHello!");
print("\tA vector named \"t0\" has been set as:\n\n\t\tt0=vector(s,j,numerator(g01(j,s\\2)));\n\n\t(At purpose, by default s=25)");
print("\n\nPlease type \"t0\" and hit Enter...\n");

/* Sample output (Linux) below: ----------

remy: ~/cano/current >  gp -q fab.gp.txt

Hello!
        A vector named "t0" has been set as:

                t0=vector(s,j,numerator(g01(j,s\2)));

        (At purpose, by default s=25)


Please type "t0" and hit Enter...

? t0
[-61035156, -12207031, -2441406, -488281, -97656, -19531, -3906, -781, -156, -31, -6, -1
, 0, 1, 6, 31, 156, 781, 3906, 19531, 97656, 488281, 2441406, 12207031, 61035156]
? 

------------------------------------ */

/* Just an aid, but be careful when using it. */

vecdiff(Omega,W)=if(Omega==1,vector(#W-1,j,W[j+1]-W[j]),my(Q=vecdiff(Omega-1,W));vector(#Q-1,j,Q[j+1]-Q[j]));

u00(n)=8*sum(k=0,n-1,9^k);

/*
 * Sample output about the eigen-patterns present there in the first Nth differences for A060458
  
Hello!
        A vector named "t0" has been set as:

                t0=vector(s,j,numerator(g01(j,s\2)));

        (At purpose, by default s=25)


Please type "t0" and hit Enter...

? t0=vector(10,j,f01(j))
[8, 96, 992, 9984, 99968, 999936, 9999872, 99999744, 999999488, 9999998976]
? v0=vector(4,j,u00(j))
[8, 80, 728, 6560]
? t1=vecdiff(4,t0)
[65608, 656096, 6560992, 65609984, 656099968, 6560999936]
? t2=vector(#t1,j,v0[4]*(10^j)+t0[j])
[65608, 656096, 6560992, 65609984, 656099968, 6560999936]
? (t2==t1)
1
?
? / * If the property was correctly interpreted, below must be shown a "pizza triangle" made with zeros * /
?
? for(k=1,s-1,print(vecdiff(k,t0)-(vector(#t0-k,i,t0[i])+vector(#t0-k,l,(10^l)*u00(k)))))
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0]
[0, 0]
[0]
? 
? /* "Al Giorno!" (It works fine in the way already interpreted and proposed by the author) */

 *
*/ 


/*
 * Bonus code:
 * 	The right-hand side of f15() leaving only numerals and evaluating 5*n.
 */

lookthis(n=5)=print("9"5*n"141529"); 

/*
 * Some random thoughts:
 * 
 *	Another curiosity, (92514-41529)=50985, you can pick "50985" and evaluate "50(9-8)05" getting "50105"
 *	then evaluate "501-105" what is "396" which might become "3(6+3)6", then "(3+6)(3+6)" and finally
 *	"99" and since "9-9" is zero (the most trivial "palindrome" due it is usually represented by
 *	either a thin and symmetric closed curve or a dot) this is undoubtedly...
 * 
 * tHe eND */